scsi: core: Put LLD module refcnt after SCSI device is released
authorMing Lei <ming.lei@redhat.com>
Fri, 8 Oct 2021 05:01:18 +0000 (13:01 +0800)
committerSalvatore Bonaccorso <carnil@debian.org>
Wed, 3 Nov 2021 14:35:31 +0000 (14:35 +0000)
commitb993b07ccc476e67cc46e3b33956cb48639be9c3
tree7ebb8b35d7365467cc851433c6039907c801df83
parentff5c23ee2ee398162ae5b4369f703182f7c54c2c
scsi: core: Put LLD module refcnt after SCSI device is released

Origin: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git/commit?id=6aa47b0134d4df6005a2385156e6fe81961dadf8

commit f2b85040acec9a928b4eb1b57a989324e8e38d3f upstream.

SCSI host release is triggered when SCSI device is freed. We have to make
sure that the low-level device driver module won't be unloaded before SCSI
host instance is released because shost->hostt is required in the release
handler.

Make sure to put LLD module refcnt after SCSI device is released.

Fixes a kernel panic of 'BUG: unable to handle page fault for address'
reported by Changhui and Yi.

Link: https://lore.kernel.org/r/20211008050118.1440686-1-ming.lei@redhat.com
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Reported-by: Changhui Zhong <czhong@redhat.com>
Reported-by: Yi Zhang <yi.zhang@redhat.com>
Tested-by: Yi Zhang <yi.zhang@redhat.com>
Signed-off-by: Ming Lei <ming.lei@redhat.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Gbp-Pq: Topic bugfix/all
Gbp-Pq: Name scsi-core-Put-LLD-module-refcnt-after-SCSI-device-is.patch
drivers/scsi/scsi.c
drivers/scsi/scsi_sysfs.c